package com.eveinfo.api.asset;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.eveinfo.api.AbstractApiParser;
import com.eveinfo.api.ApiAuth;
import com.eveinfo.api.ApiException;
import com.eveinfo.api.NoCacheFoundExecption;

public class AssetParser extends AbstractApiParser<AssetResponse, AssetHandler> {
	protected static final String ASSETLIST_URL = "/AssetList.xml.aspx";

	private static AssetParser instance;

	public static AssetParser getInstance() {
		if (instance == null) {
			instance = new AssetParser();
		}
		return instance;
	}

	public static boolean isInstancier() {
		return instance != null;
	}

	private AssetParser() {
		super(AssetResponse.class, 2, ASSETLIST_URL);
	}

	public AssetResponse getAssets(ApiAuth auth, boolean corporation) throws IOException, SAXException,
			ParserConfigurationException, ApiException, NoCacheFoundExecption {
		AssetHandler handler = new AssetHandler();
		if (corporation)
			return getResponse(auth, Path.CORP, handler);
		return getResponse(auth, Path.CHARACTER, handler);
	}
}